/*
 * @lc app=leetcode.cn id=495 lang=csharp
 *
 * [495] 提莫攻击
 */

// @lc code=start
public class Solution {
    public int FindPoisonedDuration(int[] timeSeries, int duration) {
        int totalSecond = 0;
        int lastHitSecond = timeSeries[0];
        foreach (var hitSecond in timeSeries)
        {
            if (lastHitSecond + duration < hitSecond)
            {
                totalSecond += duration;
            }
            else
            {
                totalSecond += hitSecond - lastHitSecond;
            }
            lastHitSecond = hitSecond;
        }
        return totalSecond + duration;
    }
}
// @lc code=end

